package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-03-10
 * Time: 12:56
 */
public class Search implements Ioperation {
    @Override
    public void work(BookList bookList) {
        System.out.println("请输入要查找的书名");
        Scanner scanner = new Scanner(System.in);
        String bookName = scanner.nextLine();
        for (int i = 0; i < bookList.getUsedSize(); i++) {
            Book book = bookList.getBook(i);
            if (book.getName().equals(bookName)) {
                System.out.println("找到了");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没找到你要查找的书!!!");
    }
}
